package com.tedu.udm.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.tedu.udm.pojo.dto.UserAddNewDTO;
import com.tedu.udm.service.IUserTeamService;
import com.tedu.udm.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Api(tags = "97. 小组学员管理模块")
@Validated
@RestController
@RequestMapping("/userTeams")
public class UserTeamController {
    @Autowired
    private IUserTeamService userTeamService;

    // http://localhost:9878/users/add-new?username=aa&phone=bb&email=cc
    @ApiOperation("添加小组成员")
    @ApiOperationSupport(order = 100)
    @PostMapping("/{id:[0-9]+}/add-new")
    public JsonResult<Void> addNew(@Range(min = 1, message = "删除用户失败，尝试删除的用户的ID无效！")
                                       @PathVariable Long teamid,Long[] userIds) {
        log.debug("开始处理【添加小组成员】的请求，参数：{}", teamid);
        userTeamService.addNew(teamid,userIds);
        return JsonResult.ok();
    }
}
